<?php 
/**
 * PORTFOLIO 1 Leftsidebar
 * The main template file for display portfolio page.
 *
 * @package WordPress
*/
wp_enqueue_script('prettyPhoto');
$types_arr=array();
if(get_theme_option('portfolio','portfolio_enable_filter') =='true' ):
    $types=get_terms('portfolio-types');
	$num=0;
		if($types) :
           foreach($types as $type):
        		$types_arr[$num]='<li><a href="#'.str_replace(' ','-',$type->name).'">'.$type->name.'</a></li>'."\n";
        		$num++;
           endforeach;
		 endif;
?>
                    <div class="seperator">
                    	<ul id="portfolio-filter">
                            <li><a href="#all" title="">All</a></li>
                            <?php echo implode(' ',$types_arr);?>
                        </ul>
                    </div>
					<div class="home-blog">
						 <ul id="portfolio-list">					
<?php endif; 
global $posts;
$curr_count=0;
$sum = 0;
while(have_posts()): the_post();
//Get setting
$enable_lightbox = get_theme_option('portfolio','portfolio_enable_lightbox');
$enable_filter = get_theme_option('portfolio','portfolio_enable_filter');
$image = get_meta_option('image_upload_portfolio',get_the_ID());

$video = get_meta_option('video_embed_code',get_the_ID());
$video_embed=get_meta_option('video_embed_code',get_the_ID());
$youtube_video = get_meta_option('youtube_id',get_the_ID());
$vimeo_video = get_meta_option('vimeo_id',get_the_ID());
$video_style = get_meta_option('video_style',get_the_ID());


$direct_link = get_meta_option('direct_url_portfolio',get_the_ID());

$portfolio_number_chacter =get_theme_option('portfolio','portfolio_number_chacter');
$portfolio_number_chacter =get_theme_option('portfolio','portfolio_number_chacter');
$portfolio_readmore_link =get_theme_option('portfolio','portfolio_readmore_link');

  $sum++;
  $image_thumb = '';
  if(has_post_thumbnail(get_the_ID())):
    $images_id=get_post_thumbnail_id(get_the_ID());
    $image_thumb=wp_get_attachment_image_src($images_id,'194-148');
	$type_portfolio = get_meta_option('portfolio_type',get_the_ID());
  endif;
  $types_portfolio=get_the_terms(get_the_ID(),'portfolio-types');
  $types_portfolio_arr = array();
  $num=0;
  if($types_portfolio) :
     foreach($types_portfolio as $type):
        $types_portfolio_arr[$num]=str_replace(' ','-',$type->name);
        $num++;
     endforeach;
 endif;
?>


						 
                            <li class="<?php echo implode(' ',$types_portfolio_arr);?>">
                                <div class="blog-shadow">
                                    <div class="blog-img">
                                         <?php if(!empty($image_thumb)) :?>
									  
        							     	   <img src="<?php echo get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_thumb[0]; ?>&amp;h=148&amp;w=194&amp;zc=1" alt="<?php the_title()?>">
               						
       								  	 <?php endif;?>
                                        <div class="blog-date">
                                            <?php echo get_the_time('M'); ?> / <?php echo get_the_time('d'); ?>
                                        </div>
                                        
                                    </div>
                                    <h2><?php the_title();?></h2>
                                    <?php
                              			$exceptlength= get_theme_option('portfolio','portfolio_number_chacter'); 
                              		?>
                                    <p>
                              		   <?php echo tt_substr(get_the_excerpt(),$exceptlength);?>
                                    
                              		<?php 
                              			$readmore = get_theme_option('portfolio','portfolio_readmore_link');
                              			if($readmore <> '') : 
                              		?>
                              
                              			<div class="readmore"><a class="rm-link" href="<?php the_permalink();?>"><?php echo $readmore;?></a></div>
            						</p>
                              		<?php 
                              			endif;
                              		?>                                    
                                </div>
                            </li>
                            
	
<?php endwhile; ?>
	  			  			<li style="overflow: hidden; clear: both; height: 0px; position: relative; float: none; display: block;"></li>
                        
						</ul>
					</div>
<?php tt_pagination(); ?>					 